using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScoreManager : MonoBehaviour
{
    public static ScoreManager Instance { get; private set; }


    public GameObject score;

    public Sprite[] score3000;
    public Sprite[] score5000;
    public Sprite[] score10000;


    private Dictionary<int, Sprite[]> scoreDict;


    private void Awake()
    {
        Instance = this;
    }


    // Start is called before the first frame update
    void Start()
    {
        scoreDict = new Dictionary<int, Sprite[]>();
        scoreDict.Add(3000, score3000);
        scoreDict.Add(5000,score5000);
        scoreDict.Add(10000,score10000);
    }
    public void ShowScore(Vector3 position,int s)
    {
        GameObject scoreGo= GameObject.Instantiate(score,position,Quaternion.identity);
        Sprite[] scoreArray;
        scoreDict.TryGetValue(s,out scoreArray);
        int index= Random.Range(0,scoreArray.Length);
        Sprite sprite= scoreArray[index];
        scoreGo.GetComponent<SpriteRenderer>().sprite = sprite;
        Destroy(scoreGo,1f);
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}
